﻿//-----------------------------------------------------------------------
// <copyright file="ProcessingServiceSection.cs" company="FastNET Services">
//     Copyright (c) 2007-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings
using System.Configuration;
#endregion

namespace FastNET.CleanAct.Client.Configuration.ProcessingServices
{
    /// <summary>
    /// This class is actually what loads the custom settings.
    /// </summary>
    public class ProcessingServiceSection : ConfigurationSection
    {
        #region Constants

        private const string CONFIG_SECTION_NAME = "processingServices";

        #endregion

        #region Public Static Methods

        /// <summary>
        /// Gets the configuration for the processing service section from the current configuration
        /// </summary>
        public static ProcessingServiceSection GetConfigurationSection()
        {
            return (ProcessingServiceSection)ConfigurationManager.GetSection(CONFIG_SECTION_NAME);
        }

        #endregion

        #region Public Collections

        /// <summary>
        /// Gets a list of all the services associated with the configuration
        /// </summary>
        [ConfigurationProperty("services", IsDefaultCollection = false)]
        [ConfigurationCollection(typeof(ProcessingServiceElementCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")]
        public ProcessingServiceElementCollection Services
        {
            get
            {
                return (ProcessingServiceElementCollection)this["services"] ?? new ProcessingServiceElementCollection();
            }
        }

        #endregion
    }
}